package com.itc.job.task;

import com.itc.common.core.constant.SecurityConstants;
import com.itc.system.api.FlightOperationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component("FlightOperationMonitoringTask")
public class FlightOperationMonitoringTask {
    @Resource
    private FlightOperationService flightOperationService;

    @Autowired
    private JdbcTemplate jdbcTemplate;

    public void monitorDataUpdate()
    {
        System.out.println("航班运行监控api宽表数据任务开始============================================");

        flightOperationService.monitorDataUpdate(SecurityConstants.INNER);

//        flightOperationService.ptdDataUpdate();

        flightOperationService.alarmTrigger(SecurityConstants.INNER);

        System.out.println("航班运行监控api宽表数据任务结束============================================");
    }

    public void tableDebrisClean()
    {
        System.out.println("库表数据碎片定时清理任务开始============================================");

        jdbcTemplate.execute("VACUUM FULL VERBOSE ANALYZE flight_time_exchange");
        jdbcTemplate.execute("VACUUM FULL VERBOSE ANALYZE oa_dept");
        jdbcTemplate.execute("VACUUM FULL VERBOSE ANALYZE oa_user");

        System.out.println("库表数据碎片定时清理任务结束============================================");
    }

    public void timeslotExchange()
    {
        System.out.println("时隙交换航班信息同步任务开始============================================");

        flightOperationService.timeslotExchange(SecurityConstants.INNER);

        System.out.println("时隙交换航班信息同步任务结束============================================");
    }

    public void oaDeptUserDataUpdate()
    {
        System.out.println("OA部门用户信息同步任务开始============================================");

        flightOperationService.oaDeptUserDataUpdate(SecurityConstants.INNER);

        flightOperationService.aocScheduleUpdate(SecurityConstants.INNER);

        System.out.println("OA部门用户信息同步任务结束============================================");
    }
}
